<?php
/**
 * Formulário padrão
 */
class App_Form_Compra extends Voitech_Form
{
	public function __construct($arrParam)
	{
		parent::__construct(array());
		
		$this->setAttribs(array('name'=>'frmCadastroCompra', 'id'=>'frmCadastroCompra', 'class'=>'form last-child'));
		
		// add id element
                $this->addElement('hidden', 'co_compra');

                // remove id's decorators
                $this->getElement('co_compra')
                    ->removeDecorator('DtDdWrapper')
                    ->removeDecorator('HtmlTag')
                    ->removeDecorator('Label');

		$coFornecedor 	= new Zend_Form_Element_Select( 'co_fornecedor' );
		$coFornecedor->setLabel( 'Fornecedor:' )
                             ->addMultiOptions($arrParam['arrFornecedor'])
                             ->addFilter( new Zend_Filter_StringTrim() )
                             ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'4', 'max'=>'155' ) ) )
                             ->setDecorators( $this->_decoratorLeft )
                             ->setRequired( true );
		$this->addElement( $coFornecedor );
                
                $buttonCdstFornecedor = new Zend_Form_Element_Button('Cadastrar Fornecedor');
		$buttonCdstFornecedor->setAttribs( array('class'=> 'first-child last-child', 'id' => 'btnCadastrarFornecedor' ) )
		           ->setDecorators( $this->_decoratorDefault )
		           ->removeDecorator( 'label' );
                $this->addElement( $buttonCdstFornecedor );
                
                $tipoCompra = new Zend_Form_Element_Select( 'co_tipo_compra' );
		$tipoCompra->setLabel( 'Tipo de Compra:' )
                             ->addMultiOptions($arrParam['arrTipoCompra'])
                             ->addFilter( new Zend_Filter_StringTrim() )
                             ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'4', 'max'=>'155' ) ) )
                             ->setDecorators( $this->_decoratorDefault )
                             ->setRequired( true );                
                $this->addElement( $tipoCompra );
		
		$nuNota = new Zend_Form_Element_Text( 'nu_nota' );
		$nuNota->setLabel( 'Nota Fiscal/Controle:' )
			   ->setAttribs( array( 'size'=>'15' ) )
			   ->addFilter( new Zend_Filter_StringTrim() )
			   ->addFilter( new Zend_Filter_Alnum() )
			   ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'20' ) ) )
			   ->addValidator( new Zend_Validate_Alnum() )
			   ->setDecorators( $this->_decoratorDefault )
			   ->setRequired( true );
		$this->addElement( $nuNota );
                
                $buttonCancelar = new Zend_Form_Element_Button('Cancelar');
		$buttonCancelar->setAttribs( array('class'=> 'first-child last-child','style'=>'float:left;margin-top: 17px', 'id' => 'btnCancelar' ) )
		           ->removeDecorator( 'label' );
		$this->addElement( $buttonCancelar );	

		$buttonCdst = new Zend_Form_Element_Button('Salvar');
		$buttonCdst->setAttribs( array('class'=> 'first-child last-child','style'=>'float:right; margin-top: 17px', 'id' => 'btnSalvar' ) )
		           ->setDecorators( $this->_decoratorLeft )
		           ->removeDecorator( 'label' );
		
		$this->addElement( $buttonCdst );		
		$this->addDisplayGroup(array('co_fornecedor','btnCadastrarFornecedor','co_tipo_compra','nu_nota','Cancelar', 'Salvar'),'Cadastro',array('legend' => 'Formulario de cadastro de fornecedor', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));
	}
}